package com.zdsoft.crm.controller.clue;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.zdsoft.crm.service.clue.echarts.IClueEChartsService;
import com.zdsoft.crm.service.clue.echarts.ICluePoolEChartsService;
import com.zdsoft.crm.service.clue.echarts.IEChartsService;
import com.zdsoft.crm.util.DateUtil;
import com.zdsoft.crm.vo.clue.echarts.ClueChargeEChartsVo;
import com.zdsoft.crm.vo.clue.echarts.ClueCreateEChartsVo;
import com.zdsoft.crm.vo.clue.echarts.ClueDateEChartsVo;

@Controller
@RequestMapping("/clue/ECharts")
public class ClueEchartsController {
	
	@Autowired
	IEChartsService eChartsService;
	
	@Autowired
	IClueEChartsService clueEChartsService;
	
	@Autowired
	ICluePoolEChartsService cluePoolEChartsService;

	/**
	 * 全部统计
	 * @return
	 */
	@GetMapping("/")
	public ModelAndView ECharsUI(){
		ModelAndView mav=new ModelAndView("/clue/echarts/echarts.html");
		String firstDayOfWeek = DateUtil.getFirstDayOfWeek().toString();
		String lastDayOfWeek = DateUtil.getLastDayOfWeek().toString();
		
		List<ClueDateEChartsVo> listEChartsDate = eChartsService.EChartsDate(firstDayOfWeek, lastDayOfWeek);
		List<ClueDateEChartsVo> listEChartsDateAll = eChartsService.EChartsDateAll();
		List<ClueCreateEChartsVo> listEChartsCreate = eChartsService.EChartsCreate();
		
		mav.addObject("eChartsDate", listEChartsDate);
		mav.addObject("eChartsDateAll", listEChartsDateAll);
		mav.addObject("eChartsCreate", listEChartsCreate);
		
		return mav;
	}
	
	/**
	 * 线索统计
	 * @return
	 */
	@GetMapping("/clueECharts")
	public ModelAndView clueECharsUI(){
		ModelAndView mav=new ModelAndView("/clue/echarts/clue_echarts.html");
		String firstDayOfWeek = DateUtil.getFirstDayOfWeek().toString();
		String lastDayOfWeek = DateUtil.getLastDayOfWeek().toString();
		
		List<ClueDateEChartsVo> listEChartsDate = clueEChartsService.EChartsDate(firstDayOfWeek, lastDayOfWeek);
		List<ClueDateEChartsVo> listEChartsDateAll = clueEChartsService.EChartsDateAll();
		List<ClueCreateEChartsVo> listEChartsCreate = clueEChartsService.EChartsCreate();
		List<ClueChargeEChartsVo> listEChartsCharge = clueEChartsService.EChartsCharge();
		
		mav.addObject("eChartsDate", listEChartsDate);
		mav.addObject("eChartsDateAll", listEChartsDateAll);
		mav.addObject("eChartsCreate", listEChartsCreate);
		mav.addObject("eChartsCharge", listEChartsCharge);
		
		return mav;
	}
	
	/**
	 * 线索池统计
	 * @return
	 */
	@GetMapping("/cluePoolECharts")
	public ModelAndView cluePoolECharsUI(){
		ModelAndView mav=new ModelAndView("/clue/echarts/cluepool_echarts.html");
		String firstDayOfWeek = DateUtil.getFirstDayOfWeek().toString();
		String lastDayOfWeek = DateUtil.getLastDayOfWeek().toString();
		
		List<ClueDateEChartsVo> listEChartsDate = cluePoolEChartsService.EChartsDate(firstDayOfWeek, lastDayOfWeek);
		List<ClueDateEChartsVo> listEChartsDateAll = cluePoolEChartsService.EChartsDateAll();
		List<ClueCreateEChartsVo> listEChartsCreate = cluePoolEChartsService.EChartsCreate();
		
		mav.addObject("eChartsDate", listEChartsDate);
		mav.addObject("eChartsDateAll", listEChartsDateAll);
		mav.addObject("eChartsCreate", listEChartsCreate);
		
		return mav;
	}
}
